layui.config({
    base : "/layui/"
}).extend({
    index: 'lib/index'
}).use(['index','form','jquery', 'table'],function(){
    var form = layui.form,
        table=layui.table,
        admin  = layui.admin;

        table.render({
            elem: '#income_table'
            ,url: '/income/queryData'
            ,method:"post"
            ,height: 500
            ,limit:50							//显示数目
            ,limits:[50,100]
            ,cols: [[
                {field:'srcUserName', title: '商家名称',width:200, "align":"center"}
                ,{field:'type',width:200, title: '类型',"align":"center",templet:function (d) {
                     var type =d.type;
                    if(type==1){
                        return "用户消费";
                    }else if(type==2){
                        return "商家推荐";
                    }else if(type==3){
                        return "设备分佣";
                    }else if(type==4){
                        return "代理商推荐";
                    }
                }}
               ,{field:'money',width:200, title: '金额/元',"align":"center",templet:function (d) {
                    return new Number(d.money.toString()).div(new Number(100));
                 }}
                ,{field:'totalFee',width:200, title: '原始订单金额',"align":"center",templet:function (d) {
                        return new Number(d.totalFee.toString()).div(new Number(100));
                    }}
                ,{field:'createdTime',width:200, title: '创建时间',"align":"center"}

            ]]
            ,request:{
                pageName: 'pageNo' //页码的参数名称，默认：page
                ,limitName: 'pageSize' //每页数据量的参数名，默认：limit
            },
            where:{}
            ,id: 'income_table'
            ,page: true
        });

        $(".search_btn").click(function () {
            var type = $(".queryTable select[name='type']").val();
            console.log(type);
            table.reload('income_table', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                ,where: {
                    type:type,
                    srcUserName:$(".queryTable input[name='srcUserName']").val()
                }
            });
        });

})

